<?php
error_reporting(E_ALL || ~E_NOTICE);
ini_set('date.timezone','Asia/Shanghai');
set_time_limit(0);
ini_set('memory_limit','50M');
header("Content-type:text/html;charset=utf-8");
?>
<style type="text/css">
blockquote,body,button,dd,dl,dt,fieldset,form,h1,h2,h3,h4,h5,h6,hr,input,legend,li,ol,p,pre,td,textarea,th,ul{margin:0;padding:0}
html{color:#000;overflow-y:scroll;overflow:-moz-scrollbars}
body,button,input,select,textarea{font-size:13px;font-family:"PingFang SC",Arial,"Microsoft YaHei",sans-serif}
h1,h2,h3,h4,h5,h6{font-size:100%}
em{font-style:normal}
small{font-size:12px}
ol,ul{list-style:none}
a{text-decoration:none}
a:hover{text-decoration:underline}
legend{color:#000}
fieldset,img{border:0}
button,input,select,textarea{font-size:100%}
table{border-collapse:collapse;border-spacing:0}
img{-ms-interpolation-mode:bicubic}
textarea{resize:vertical}
</style>
<?php
//重要目录修改
$data_name = 'data_'.GetRandStr(6);
$include_name = 'include_'.GetRandStr(6);
$templets_name = 'templets_'.GetRandStr(6);
$plus_name = 'plus_'.GetRandStr(6);
$member_name = 'member_'.GetRandStr(6);

$gai_dirname = array(
	array('data',$data_name),
	array('include',$include_name),
	array('templets',$templets_name),
	array('plus',$plus_name),
	array('member',$member_name),
);
$str0 = array();
$str_data = array(
	"'filedir'=>'/data/js'##'filedir'=>'/".$data_name."/js'",
	'../data/vote/##../'.$data_name.'/vote/',
	'../data/mail##../'.$data_name.'/mail',
	"DEDEROOT.'/data'##DEDEROOT.'/".$data_name."'",
	'cfg_basedir."/data/##cfg_basedir."/'.$data_name.'/',
	"addDir('/data/js', '##addDir('/".$data_name."/js', '",
	'cfg_cmspath."/data/##cfg_cmspath."/'.$data_name.'/',
	"addDir('/data/js',##addDir('/".$data_name."/js',",
	'safefile = "data/common.inc.php##safefile = "'.$data_name.'/common.inc.php',
	'preg_match("#data/tplcache|.svn##preg_match("#'.$data_name.'/tplcache|.svn"',
	'preg_match("#data\/#", $cfg_tplcache_dir)##preg_match("#'.$data_name.'\/#", $cfg_tplcache_dir)',
	'../data/baidunews.xml##../'.$data_name.'/baidunews.xml',
	'activepath."/data/mail"##activepath."/'.$data_name.'/mail"',
	'../data/enums/area.js##../'.$data_name.'/enums/area.js',
	"cfg_basehost.'/data/##cfg_basehost.'/".$data_name."/",
	'cfg_cmspath/data/##cfg_cmspath/'.$data_name.'/',
	"GLOBALS['cfg_cmspath']}/data/##GLOBALS['cfg_cmspath']}/".$data_name."/",
	"GLOBALS['cfg_mainsite']}/data/##GLOBALS['cfg_mainsite']}/".$data_name."/",
	"GLOBALS['cfg_cmspath'].\"/data/##GLOBALS['cfg_cmspath'].\"/".$data_name."/",#88
	"define('DEDEDATA', DEDEROOT.'/data');##define('DEDEDATA', DEDEROOT.'/".$data_name."');",
	"cfg_cmspath.'/data'##cfg_cmspath.'/".$data_name."'",
	"DEDEINC.'/../data/##DEDEINC.'/../".$data_name."/",
	'dirname(__FILE__)."/../../data/##dirname(__FILE__)."/../../'.$data_name.'/',
	"GLOBALS['cfg_cmsurl'].\"/data/##GLOBALS['cfg_cmsurl'].\"/".$data_name."/",#88
	'{$cmspath}data/##{$cmspath}'.$data_name.'/',
	"dirname(__FILE__).'/data/common.inc.php')##dirname(__FILE__).'/".$data_name."/common.inc.php')",
	"cfg_tplcache_dir = '/data/tplcache';##cfg_tplcache_dir = '/".$data_name."/tplcache';",
	"DEDEROOT.'/data/module'##DEDEROOT.'/".$data_name."/module'",
	"dirname(__FILE__).'/../data/##dirname(__FILE__).'/../".$data_name."/",
	"timelock = '../data/time.lock';##timelock = '../".$data_name."/time.lock';",
	'href="../include/calendar##href="../'.$data_name.'/calendar',
	'{dede:global.cfg_cmsurl/}/data/##{dede:global.cfg_cmsurl/}/'.$data_name.'/',
	'src="../data/mark/##src="../'.$data_name.'/mark/'
);
$str_include = array(
	'DEDEINC."/../include/##DEDEINC."/../'.$include_name.'/',
	"'/include/dialog/##'/".$include_name."/dialog/",
	'"/include/dialog/##"/'.$include_name.'/dialog/',
	"'../include/dialog/##'../".$include_name."/dialog/",
	'"../include/dialog/##"../'.$include_name.'/dialog/',
	'{$cfg_cmspath}/include$##{$cfg_cmspath}/'.$include_name.'$',
	"GLOBALS['cfg_cmspath'].'/include/##GLOBALS['cfg_cmspath'].'/".$include_name."/",
	'dirname(__FILE__) . "/include/##dirname(__FILE__) . "/'.$include_name.'/',
	'cfg_cmsurl}/include/##cfg_cmsurl}/'.$include_name.'/',
	'dirname(__FILE__)."/../../include/##dirname(__FILE__)."/../../'.$include_name.'/',
	"dirname(__FILE__).'/../../include/##dirname(__FILE__).'/../../".$include_name."/",
	'dirname(__FILE__) . "/../include/##dirname(__FILE__) . "/../'.$include_name.'/',
	"dirname(__FILE__).'/../../include/##dirname(__FILE__).'/../../".$include_name."/",
	"dirname(__FILE__).'/../include/##dirname(__FILE__).'/../".$include_name."/",
	'dirname(__FILE__)."/../include/##dirname(__FILE__)."/../'.$include_name.'/',
	'dirname(__FILE__) . "/include/##dirname(__FILE__) . "/'.$include_name.'/',
	'{dede:global.cfg_cmspath/}/include/##{dede:global.cfg_cmspath/}/'.$include_name.'/',
	"cfg_cmspath.'/include/##cfg_cmspath.'/".$include_name."/",
	'{dede:global.cfg_cmsurl/}/include/##{dede:global.cfg_cmsurl/}/'.$include_name.'/',
	"src='../include/##src='../".$include_name."/",
	'src="../include/##src="../'.$include_name.'/',
	"src = '../include/##src = '../".$include_name."/",
	', substr(DEDEINC,0,-8) ) );##, substr(DEDEINC,0,-'.strlen($include_name).') ) );',
	"DEDEADMIN.'/../include/##DEDEADMIN.'/../".$include_name."/",
	"preg_replace('#'.\$cfg_cmspath.'\\/include\$#i', '', DEDEINC)##preg_replace('#'.\$cfg_cmspath.'\\/".$include_name."\$#i', '', DEDEINC)"
);
$str_templets = array(
	"'filedir'=>'/templets/##'filedir'=>'/".$templets_name."/",
	'../templets/plus/##../'.$templets_name.'/plus/',
	'../templets/wap##../'.$templets_name.'/wap',
	'"/templets/default/##"/'.$templets_name.'/default/',
	"cfg_cmspath.'/templets';##cfg_cmspath.'/".$templets_name."';",
	"DEDEROOT.'/templets'##DEDEROOT.'/".$templets_name."'",
	"DEDEROOT.'/templets/##DEDEROOT.'/".$templets_name."/",
	'DEDEROOT."/templets/##DEDEROOT."/'.$templets_name.'/',
	'"/templets/default##"/'.$templets_name.'/default',
	'url(../templets/##url(../'.$templets_name.'/',
	'url(/templets/##url(/'.$templets_name.'/'
);
$str_plus = array(
	'../plus/##../'.$plus_name.'/',
	"cfg_cmspath.'/plus/##cfg_cmspath.'/".$plus_name."/",
	'<?php echo $cfg_cmsurl;?>/plus/##<?php echo $cfg_cmsurl;?>/'.$plus_name.'/',
	'src="/plus/img##src="/'.$plus_name.'/img',
	"= $cfg_cmspath.'/plus';##= $cfg_cmspath.'/".$plus_name."';",
	"<a href='/plus/##<a href='/".$plus_name."/",
	'return_url = "/plus/##return_url = "/'.$plus_name.'/',
	'<a href="plus/feedback.php##<a href="'.$plus_name.'/feedback.php',
	"href='{$baseurl}plus/##href='{$baseurl}".$plus_name."/",
	"'/plus/view.php##'/".$plus_name."/view.php",
	'<?php echo $cfg_cmspath;?>/plus/##<?php echo $cfg_cmspath;?>/'.$plus_name.'/',
	'href="/plus/##href="/'.$plus_name.'/',
	'{dede:global.cfg_cmsurl/}/plus/##{dede:global.cfg_cmsurl/}/'.$plus_name.'/',
	'="plus/flink##="'.$plus_name.'/flink',
	"action='/plus/##action='/".$plus_name."/"
);

$str_member = array(
	'location:../member/##location:../'.$member_name.'/',
	'jumpurl=../member/##jumpurl=../'.$member_name.'/',
	'"../member/templets/##"../'.$member_name.'/templets/',
	'src="../../member/##src="../../'.$member_name.'/',
	"define('DEDEMEMBE', DEDEROOT.'/member');##define('DEDEMEMBE', DEDEROOT.'/".$member_name."');",
	"cfg_cmspath.'/member';##cfg_cmspath.'/".$member_name."';",
	"orderurl = '../member/##orderurl = '../".$member_name."/",
	"<a href='/member'>##<a href='/".$member_name."'>",
	"GLOBALS['cfg_basehost'].'/member/##GLOBALS['cfg_basehost'].'/".$member_name."/",
	'cfg_basehost."/member/##cfg_basehost."/'.$member_name.'/',
	"', '/member');##', '/".$member_name."');",
	'cfg_cmspath)."/member/##cfg_cmspath)."/'.$member_name.'/',
	'<?php echo $cfg_cmsurl;?>/member/##<?php echo $cfg_cmsurl;?>/'.$member_name.'/',
	'href="/member/##href="/'.$member_name.'/',
	'<?php echo $cfg_cmspath; ?>/member/##<?php echo $cfg_cmspath; ?>/'.$member_name.'/',
	'src="../member/templets/##src="../'.$member_name.'/templets/',
	'","/member/shops_orders.php"##","/'.$member_name.'/shops_orders.php"',
	'{$cfg_cmspath}/member/##{$cfg_cmspath}/'.$member_name.'/',
	'cfg_cmspath."/member/##cfg_cmspath."/'.$member_name.'/',
	'cfg_basehost."/member";##cfg_basehost."/'.$member_name.'";',
	'{dede:global.cfg_cmspath/}/member/##{dede:global.cfg_cmspath/}/'.$member_name.'/',
	"location='/member/##location='/".$member_name."/",
	'{dede:global.cfg_cmsurl/}/member/##{dede:global.cfg_cmsurl/}/'.$member_name.'/',
	'="/member/templets/##="/'.$member_name.'/templets/',
	"cfg_basehost.'/member/##cfg_basehost.'/".$member_name."/",
	'"../member"##"../'.$member_name.'"',
	'","../member/##","../'.$member_name.'/',
	'href="../member/##href="../'.$member_name.'/',
	"href='../member/##href='../".$member_name."/",
	"href='/member/##href='/".$member_name."/"
);


//全局内容替换
$str_all = array(
	'上海卓卓网络科技有限公司##',
	'@link           http://www.dedecms.com##',
	'http://help.dedecms.com/usersguide/license.html##',
	'        DedeCMS.##',
	'"DedeCMS Error: Request Error!"##"Request Error!"',
	', 上海卓卓网络科技有限公司 (DesDev, Inc.)##',
	'         DedeCMS团队##',
	'      Copyright (c) 2007 - 2021,  (DesDev, Inc.)##',
	'      http://www.dedecms.com##',
	'      DedeCMS.##',
	"exit('dedecms')##exit('CMS')",
	'<a href="http://bbs.dedecms.com/907721.html">DedeCMS:CSRF Token Check Failed!</a>##CSRF Token Check Failed!',
	"\$dhd->OpenUrl('http://www.dedecms.com/officialinfo.html');##\$dhd->OpenUrl('http://www.baidu.com/');",
	'<div><h3>DedeCMS Error Warning!</h3>##<div><h3>Error Warning!</h3>',
	"<div><a href='http://bbs.dedecms.com' target='_blank' style='color:red'>Technical Support: http://bbs.dedecms.com</a></div>##",
	"请到 http://bbs.dedecms.com 查询##",
	"photo_watertext = 'www.dedecms.com';##photo_watertext = 'www.a.com';",
	"email=admin@dedecms.com##email=admin@biadu.com",
	"url=http://www.dedecms.com##url=http://www.biadu.com",
	"<m:item name='参考文档' link='http://help.dedecms.com' rank='' target='_blank' />##",
	"<m:item name='意见建议反馈' link='http://site.desdev.cn/suggest/' rank='' target='_blank' />##",
	"<m:item name='官方交流论坛' link='http://bbs.dedecms.com' rank='' target='_blank' />##<m:item name='百度站长论坛' link='http://bbs.zhanzhang.baidu.com' rank='' target='_blank' />",
	" = fsockopen('www.dedecms.com',80## = fsockopen('www.baidu.com',80",
	'fputs($fp, "POST http://www.dedecms.com/plugin.php HTTP/1.1\r\n");##fputs($fp, "POST http://www.baidu.com/plugin.php HTTP/1.1\r\n");',
	'http://img.dedecms.com##http://img.baidu.com',
	"<a href='http://bbs.dedecms.com' target='_blank'>官方论坛</a>##",
	"<a href='http://help.dedecms.com' target='_blank'>在线帮助</a>##",
	'<a href="http://www.desdev.cn/dedecms-thanks.html" target="_blank" style="color:blue">热心用户</a>、<a href="http://www.dedecms.com/thanks.html" target="_blank" style="color:blue">赞助商</a>##',
	'<a href="http://www.desdev.cn/team.php" target="_blank" style="color:blue">织梦团队</a>##',
	'<?php echo $drgonIterm[$row]; ?>##<?php unset($drgonIterm["item2"]);unset($drgonIterm["item5"]);unset($drgonIterm["item8"]);echo $drgonIterm[$row]; ?>',
	"<a href='http://www.dedecms.com' target='_blank'><u></u></a>##",
	'<iframe name="stafrm" src="##<iframe name="stafrm" __src="',
	'title="DEDECMS 帮助中心" href="http://help.dedecms.com"##',
	'DedeCMS v5.3 Style##',
	'dedecms.com  Author pigz##',
	'<a href="http://www.dedecms.com" title="织梦内容管理系统(DedeCMS)--国内专业的PHP网站管理系统，轻松建站的利器。" target="_blank"><strong>DedeCMS##<a target="_blank"><strong>',
	'<a href="http://www.desdev.cn/" target="_blank">DesDev</a> Inc##',
	'From:DesDev INC.##',
	'<a href="http://www.dedecms.com" title="DedeCMS官网"><strong>DedeCMS##<a target="_blank"><strong>',
	'<a href="http://www.desdev.cn" target="_blank">DesDev</a> Inc.##',
	'<a href="http://www.dedecms.com/" target="_blank">DedeCMS <?php echo $cfg_version;?></a> &copy;2004-2008  <a href="http://www.desdev.cn/" target="_blank">DesDev Inc.</a>##',
	'Power by http://www.dedecms.com 织梦内容管理系统！##',
	'{dede:flinktype type="dedecms"}##{dede:flinktype}',
	'DedeCMS v5.6 Style##',
	'dedecms.com  Author Networker##',
	'Powered by <a href="http://www.dedecms.com" target="_blank">DedeCMS</a> &copy; 2004-2009  <a href="http://www.desdev.cn" target="_blank">DesDev</a> Inc.##',
	'src="http://ad.dedecms.com##_src="http://ad.dedecms.com',
	'http://flink.dedecms.com/server_url.php##http://www.baidu.com',
	'<script type="text/javascript" src="<?php echo UPDATEHOST;?>/dedecms/authorization.<?php echo $cfg_soft_lang; ?>.js"></script>##',
	"photo_watertext = 'www.dedecms.com';##photo_watertext = 'youhost';",
	'url=www.dedecms.com##url=www.a.com',
	'url=http://service.dedecms.com##url=www.a.com',
	'alt="dedecms logo" title="dedecms logo"##',
	'<span style="float:right; margin-right:20px"><a href="http://help.dedecms.com/install-use/apply/2011/1111/2131.html" target="_blank">帮助说明</a></span>##',
	'http://help.dedecms.com/install-use/apply/2013/0711/2324.html##',
	'DedeCMS Error:Tag disabled:##Error:Tag disabled:',
	'DedeCMS Error:function disabled##Error:function disabled',
	'http://2v.dedecms.com/##http://2v.baidu.com/',
	'织梦内容管理系统##内容管理系统',
	"cfg_soft_enname = 'DedeCMS';##cfg_soft_enname = 'CMS';",
	"cfg_soft_devteam = 'DedeCMS官方团队';##cfg_soft_devteam = 'CMS官方团队';",
	'revalue=<<<EOT##revalue="";$dajiodja=<<<EOT',
	'dedecms All rights reserved##',
	'href="http://help.dedecms.com" title="DEDECMS 帮助中心"##',
	'author:dedecms##author:cms',
	'name:织梦##name:',
	'exit("dedecms");##exit("cms");',
	'$GLOBALS[$v1] .= $v2;##$GLOBALS[$v1] = NULL;',
	'DedeCMS 提示信息！##提示信息！',
	'DedeCMS提示信息##提示信息',
	'DedeCMS错误警告##错误警告',
	'DedeCMS提示##提示',
	'DedeCMS OX 通用对话框##OX 通用对话框',
	'DeDeCMS系统提示：##系统提示：',
	'Welcome to DedeCMS!##Welcome to baidu',
	'by:DedeCMS团队##',
	'请把相关信息提交给DedeCMS官方##请把相关信息提交给官方',
	'fputs($fp, "Host: www.dedecms.com\r\n"); ##fputs($fp, "Host: www.baidu.com\r\n"); ',
	'assets/js/dedecms.upload.js##assets/js/upload.js',
	'assets/js/dedecms.upload.min.js##assets/js/upload.min.js',
	'assets/js/dedecms.util.js##assets/js/util.js',
	'assets/js/dedecms.util.min.js##assets/js/util.min.js',
	'dedecms-album##cms-album',
	'dedecmsAlbum##cmsAlbum',
	'admin@dedecms.com##admin@baidu.com',
	'<a href="http://www.dedecms.com" target="_blank">DedeCMS</a>##',
	'content="DedeCMS V5.6"##',
	' - Powered by DedeCMS</title>## - Powered by CMS</title>',
	'DedeCMS table Style##',
	'DedeCMS团队##',
	'package        DedeCMS.##package        ',
	'content="DedeCMS V5.3"##',
	"mid','内容管理系统','http://www.dedecms.com'); ##mid','内容管理系统','http://www.baidu.com'); ",
	'Power by DedeCMS OX##',
	'<title>DedeCMS Home</title>##<title>Home</title>',
	'src="<?php echo UPDATEHOST;?>/dedecms/admincpad##__src="<?php echo UPDATEHOST;?>/dedecms/admincpad',
	"<iframe name='stafrm' src='{\$offUrl}&uptime={\$oktime}' frameborder='0' id='stafrm' width='98%' height='50'></iframe>##",
	'<a href="http://ad.dedecms.com/ad/" target="_blank">说明</a>##',
	'DedeCMS系统配置##系统配置',
	'<title>DedeCMS menu</title>##<title>menu</title>',
	'DEDECMS 提示信息##提示信息',
	'DedeCMS模板##模板',
	'DedeCMS默认系统##默认系统',
	'<title>dedecms</title>##<title>hi</title>',
	'欢迎使用DedeCMS##欢迎使用后台',
);

//tag.php 和index.php
$two_file = array('index.php','tags.php');

//随机修改目录名
$gai_dir = array('install','special');

//随机修改文件名
$gai_file = array('images/ad1.jpg','images/ad2.jpg','images/banner01.gif','images/banner02.gif','images/banner02.jpg','images/defaultpic.gif','plus/img/toplogo.gif','plus/img/df_dedetitle.gif','plus/img/dfpic.gif','assets/img/dede_defaultpic.png','assets/img/dede_logo.png','assets/img/dedecms.png','assets/pkg/uikit/LICENSE.txt','images/dede.gif','license.txt','data/admin/allowurl.txt','member/templets/images/530x56.gif','member/templets/images/dede_banner.gif','member/templets/images/dfpic.gif','member/templets/images/login_logo.gif','member/templets/images/m_logo.gif','data/admin/source.txt','data/admin/allowurl.txt');

//修改文件名
$gai_filename = array(
	array('assets/js/dedecms.upload.js','assets/js/upload.js'),
	array('assets/js/dedecms.upload.min.js','assets/js/upload.min.js'),
	array('assets/js/dedecms.util.js','assets/js/util.js'),
	array('assets/js/dedecms.util.min.js','assets/js/util.min.js'),
);

//允许替换的目录
$allow = array('data', 'plus', 'dede', 'include', 'templets', 'member','special','m','install','assets');

$dir = str_replace("\\", "/", dirname(__FILE__));
if(!isset($_GET['houtai']) && empty($_GET['houtai'])){
	echo '本工具批量修改织梦授权 UTF-8(非utf8自己转码)<br /><form name="input" action="?" method="get">输入你的后台路径：<input type="text" name="houtai" placeholder="dede"><input type="submit" value="提交后台"></form>';
	echo '使用说明：<br />
1、将dedecms.php放置在网站根目录，与首页文件index.php放置在一起<br />
2、浏览器访问dedecms.php输入后台目录如：dede （不要加/等参数）<br />
3、点击“提交后台”，自动修改授权，并修改重要目录<br />
4、并删除此文件结束<br />
5、手动修改一下后台路径，因为每次登陆后台都会把当前环境信息发送给织梦<br />
注意：<br />1、新建站点安装完后在使用此工具<br />2、如果出现模板错误后台更新缓存<br />3、如果出现无法解决错误，请恢复备份文档<br />4、此工具不适合 二次修改过织梦内核站点'."<br /><br />\r\n";
	echo '重要提醒：本工具不删除任何文件，而是修改了部分文件名达到无法获取采证，如果图片如果出现少部分图片打不开，修改文件名或文件目录即可。<font color="#FF0000">本工具改织梦版权恢复不可逆，提示失败请忽略</font>，使用本工具，请先备份织梦程序，出问题不负任何责任，本工具会替换修改data,plus,include,templets,member目录名称，会替换如下目录文件相对应的路径data,plus,dede,include,templets,member,special,m,install,assets和index.php以及tag.php'."<br /><br />\r\n";
	echo '点击“提交后台”则表明默认使用，出问题不负责，尽量备份源文件，支持最新版织梦，本人以做测试'."<br /><br />\r\n";
	echo '点击"提交后台"后，尽量复制一下，提示信息以备未来技术修改使用，使用完工具，切记手动修改网站后台地址，因为为修改的后台路径，有加载请求把站点信息发给织梦官方'."<br />\r\n";
	echo '点击"提交后台"后，尽量复制一下，提示信息以备未来技术修改使用，使用完工具，切记手动修改网站后台地址，因为为修改的后台路径，有加载请求把站点信息发给织梦官方'."<br />\r\n";
	echo '点击"提交后台"后，尽量复制一下，提示信息以备未来技术修改使用，使用完工具，切记手动修改网站后台地址，因为为修改的后台路径，有加载请求把站点信息发给织梦官方'."<br />\r\n";
}else{
	$houtai = $_GET['houtai'];
	if(empty($houtai)){
		echo '后台不能为空，切记后台填写要准确';
		exit();
	}
	
	if(!is_dir($dir.'/'.$houtai.'/')){
		echo '后台目录不存在，输入正确的后台地址，否则会导致 后台连接不到核心文件！';
		exit();
	}
	array_push($allow,$houtai);
	$allow = array_unique($allow);

	foreach($gai_dirname as $v){
		if(file_exists($dir.'/'.$v[0].'/')){
			if($v[0] == 'data'){
				$str0 = array_merge($str0,$str_data);
				echo '重要：data修改为：'.$data_name."<br />\r\n";
			}
			if($v[0] == 'include'){
				$str0 = array_merge($str0,$str_include);
				echo '重要：include修改为：'.	$include_name."<br />\r\n";
			}
			if($v[0] == 'templets'){
				$str0 = array_merge($str0,$str_templets);
				echo '重要：templets修改为：'.$templets_name."<br />\r\n";
			}
			if($v[0] == 'plus'){
				$str0 = array_merge($str0,$str_plus);
				echo '重要： plus修改为：'.$plus_name."<br />\r\n";
			}
			if($v[0] == 'member'){
				$str0 = array_merge($str0,$str_member);
				echo '重要：member修改为：'.$member_name."<br />\r\n";
			}
		}else{
			echo $dir.'/'.$v[0].'/'."目录不存在<br />\r\n";
		}
	}
	
	$str_ar = array();
	$str_all = array_merge($str_all,$str0);
	foreach($str_all as $v){
		$ar = explode('##',$v);
		$str_ar[] = (string)$ar[0];
		$newstr_ar[] = (string)$ar[1];
	}
	foreach($allow as $v){
		list_file($dir.'/'.$v,$str_ar,$newstr_ar);
	}
	echo "<br /><br />修改index.php和tags.php<br />\r\n";
	foreach($two_file as $v){
		$a = $dir . '/' . $v;
		$contents = file_get_contents($a);
		$newstr=str_replace($str_ar,$newstr_ar,$contents);
		$fp = fopen($a, "w") or die($a."替换保存文件失败<br>\r\n");
		fwrite($fp, $newstr); 
		fclose($fp);
		echo $a."替换全局成功<br />\r\n";
	}
	echo "<br /><br />全局内容替换成功<br />\r\n";
	echo "<br /><br />修改install和special<br />\r\n";
	foreach($gai_dir as $v){
		echo gaiming($dir.'/'.$v.'/',$dir.'/'.$v.'_'.GetRandStr(6).'/')."<br />\r\n";
	}
	echo "<br /><br />修改含有dedecms的资源名<br />\r\n";
	foreach($gai_file as $v){
		echo gaiming($dir.'/'.$v,$dir.'/'.$v.'_'.GetRandStr(10))."<br />\r\n";
	}
	echo "<br /><br />重命名部分文件<br />\r\n";
	foreach($gai_filename as $v){
		echo gaiming($dir.'/'.$v[0],$dir.'/'.$v[1])."<br />\r\n";
	}
	echo "<br /><br />修改核心目录名称（data，include，templets，plus，member）<br />\r\n";
	foreach($gai_dirname as $v){
		echo gaiming($dir.'/'.$v[0],$dir.'/'.$v[1])."<br />\r\n";
	}
}

function GetRandStr($length) {
	$str = 'abcdefghijklmnopqrstuvwxyz';
	$len = strlen($str)-1;
	$randstr = '';
	for ($i=0;$i<$length;$i++) {
		$num=mt_rand(0,$len);
		$randstr .= $str[$num];
	}
	return $randstr;
}

function gaiming($file,$rename){
	if(rename($file,$rename)){ 
		echo $file."：修改成功 为".$rename; 
	}else{ 
		echo $file."：更名失败"; 
	} 
}

function list_file($dir,$str_ar,$newstr_ar) {
	if(file_exists($dir)){
		$temp = scandir($dir);
		foreach ($temp as $v) {
			if ($v == '.' || $v == '..') {
				continue;
			}
			$a = $dir . '/' . $v;
			if (is_dir($a)) {
				list_file($a,$str_ar,$newstr_ar);
			} else {
				$ext = end(explode('.',$v));
				if($ext == 'gif' || $ext == 'png' || $ext == 'jpg' || $ext == 'inc' || $ext == 'dic' || $ext == 'zip' || $ext == 'dat' || $ext == 'ttf' || $ext == 'swf' || $ext == 'otf' || $ext == 'eot' || $ext == 'svg' || $ext == 'woff'){
					continue;
				}
				$contents = file_get_contents($a);
				$newstr=str_replace($str_ar,$newstr_ar,$contents);
				$fp = fopen($a, "w") or die($a."替换保存文件失败,已经终止,疑似权限不够<br>\r\n");
				fwrite($fp, $newstr); 
				fclose($fp);
				//echo $a."替换全局成功<br />\r\n";
			}
		}
	}else{
		echo $dir."文件或目录不存在！<br />\r\n";
	}
}
echo '<br /><br />####################宝宝巴士（分享点seo知识自己搜集的）######################<br />';
echo '4414收藏的seo知识<br />';
echo '<a href="https://www.4414.cn/forum-106-2.html" target="_blank">4414站长干货 列表 https://www.4414.cn/forum-106-2.html</a><br/>
<a href="https://www.4414.cn/thread-58259-1-1.html" target="_blank">新手如何玩转采集站（欢迎交流学习）https://www.4414.cn/thread-58259-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-64563-1-1.html" target="_blank">python版 双标题组合源代码(火车头插件！) https://www.4414.cn/thread-64563-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-67620-1-1.html" target="_blank">双标题Python插件+火车头测试成功https://www.4414.cn/thread-67620-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-59585-1-1.html" target="_blank">对于收录个人一个些观点分享吧，大佬就勿喷了 https://www.4414.cn/thread-59585-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-58173-1-1.html" target="_blank">今天论坛好冷清，助个兴，8手的seo专家免费回答各类seo问题 https://www.4414.cn/thread-58173-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-66326-1-1.html" target="_blank">采集站的起死回生操作的一些方法 https://www.4414.cn/thread-66326-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-67504-1-1.html" target="_blank">去年开始做站，给大家看一看做站的情况！ https://www.4414.cn/thread-67504-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-38526-1-1.html" target="_blank">关于采集，分享下我近一月以来的faxian https://www.4414.cn/thread-38526-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-67266-1-1.html" target="_blank">几年采集站经验告你，采集站怎么做。 https://www.4414.cn/thread-67266-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-65651-1-1.html" target="_blank">不要被冯耀宗迷惑了双眼和头脑 https://www.4414.cn/thread-65651-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-41883-1-1.html" target="_blank">秒收，你们真的理解搜索引擎的秒收本质么？ https://www.4414.cn/thread-41883-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-19173-1-1.html" target="_blank">SEO网站优化标题的关键词写法 https://www.4414.cn/thread-19173-1-1.html</a><br/>
<a href="https://www.4414.cn/thread-22489-1-1.html" target="_blank">百度喜欢问答式内容?怎么一发就收录 https://www.4414.cn/thread-22489-1-1.html</a><br/>';
echo '百度站长论坛收藏seo知识<br />';
echo '<a href="http://bbs.zhanzhang.baidu.com/thread-2193210-1-1.html" target="_blank">｛备注：这里干货超级多｝百度站长论坛优质内容集合【统计】 http://bbs.zhanzhang.baidu.com/thread-2193210-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2191598-1-1.html" target="_blank">「SEO公开课」平台工具搜索展现常见问题解析 http://bbs.zhanzhang.baidu.com/thread-2191598-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2191431-1-1.html" target="_blank">「SEO公开课」数据统计常见问题解析课程 http://bbs.zhanzhang.baidu.com/thread-2191431-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2191229-1-1.html" target="_blank">「SEO公开课」平台工具使用指南 http://bbs.zhanzhang.baidu.com/thread-2191229-1-1.html</a><br/>	
<a href="http://bbs.zhanzhang.baidu.com/thread-2190516-1-1.html" target="_blank">「SEO公开课」搜索用户体验课程笔记 http://bbs.zhanzhang.baidu.com/thread-2190516-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2190429-1-1.html" target="_blank">「SEO公开课」搜索基础展现 http://bbs.zhanzhang.baidu.com/thread-2190429-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2190384-1-1.html" target="_blank">「SEO公开课」搜索时效性解读 http://bbs.zhanzhang.baidu.com/thread-2190384-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2190288-1-1.html" target="_blank">「SEO公开课」搜索权威性解读 http://bbs.zhanzhang.baidu.com/thread-2190288-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2190158-1-1.html" target="_blank">「SEO公开课」解密搜索结果排名规则 http://bbs.zhanzhang.baidu.com/thread-2190158-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2190050-1-1.html" target="_blank">「SEO公开课」搜索算法全解析 http://bbs.zhanzhang.baidu.com/thread-2190050-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2190659-1-1.html" target="_blank">2020年搜索排序+用户体验公开课大全 http://bbs.zhanzhang.baidu.com/thread-2190659-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2191521-1-1.html" target="_blank">整理线上公开课主要整理收录/索引/排名/新站等解答 http://bbs.zhanzhang.baidu.com/thread-2191521-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2192084-1-1.html" target="_blank">新站点收录排名前期注意 http://bbs.zhanzhang.baidu.com/thread-2192084-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2192126-1-1.html" target="_blank">"用户需求"的判定方式 http://bbs.zhanzhang.baidu.com/thread-2192126-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2192373-1-1.html" target="_blank">线下巡回公开课-上海站 问答整理 http://bbs.zhanzhang.baidu.com/thread-2192373-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2192444-1-1.html" target="_blank">线上公开课网站数据生产指南，问答整理 http://bbs.zhanzhang.baidu.com/thread-2192444-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2192557-1-1.html" target="_blank">线上公开课死链接处理相关 http://bbs.zhanzhang.baidu.com/thread-2192557-1-1.html</a><br/>			
<a href="http://bbs.zhanzhang.baidu.com/thread-2193038-1-1.html" target="_blank">2020年8月线上公开课：优质内容指南解读整理 	http://bbs.zhanzhang.baidu.com/thread-2193038-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2193080-1-1.html" target="_blank">2020年10月线上公开课：搜索常见问题解决指南整理 http://bbs.zhanzhang.baidu.com/thread-2193080-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2193166-1-1.html" target="_blank">2020年9月搜索基础知识合集内容整理 http://bbs.zhanzhang.baidu.com/thread-2193166-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2193275-1-1.html" target="_blank">网站抓取建设指南 内容整理 http://bbs.zhanzhang.baidu.com/thread-2193275-1-1.html</a><br/>
<a href="http://bbs.zhanzhang.baidu.com/thread-2193353-1-1.html" target="_blank">搜索体验系列解读 内容整理 http://bbs.zhanzhang.baidu.com/thread-2193353-1-1.html</a><br/>';
?>
